package com.hnkywl.sts.service.report;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.hnkywl.sts.dao.report.WlygyswlDao;
import com.hnkywl.sts.dao.report.WlykhwlDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 13-6-14
 * Time: 下午4:50
 * To change this template use File | Settings | File Templates.
 */
@Service
public class WlykhwlService {
    private WlykhwlDao wlykhwlDao;

    /**
     * 财务收发存报表
     *
     * @return
     */
    public String wlykhwlList(Long gsId,Date endDate,String khMc,Integer pageNo,Integer pageSize) {
        Map<String, Object> result = wlykhwlDao.wlykhwlList(gsId, endDate, khMc, pageNo, pageSize);
        Integer total=(Integer)result.get("total");
        List<Map> rows = (List<Map>)result.get("rows");
        List<Map> footer = (List<Map>)result.get("footer");
        Gson gson = new GsonBuilder().create();
        String rowsJson = gson.toJson(rows);
        String footerJson = gson.toJson(footer);
        String json = "{\"rows\":" + rowsJson + ",\"footer\":" + footerJson +",\"total\":"+total+ "}";
        return json;
    }



    @Autowired
    public void setWlykhwlDao(WlykhwlDao wlykhwlDao) {
        this.wlykhwlDao = wlykhwlDao;
    }
}
